package edu.hrbeu.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import edu.hrbeu.entity.Discount;
import edu.hrbeu.mapper.DiscountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;
import java.util.function.Function;

/**
 * @author wzq
 * @create 2022-01-06-12:08
 */
@Service
public class DiscountService implements IService<Discount> {

    @Autowired
    DiscountMapper discountMapper;

    @Override
    public BaseMapper<Discount> getBaseMapper() {
        return this.discountMapper;
    }

    public boolean enable(Discount discount){
        UpdateWrapper<Discount> discountUpdateWrapper = new UpdateWrapper<>();
        discountUpdateWrapper.set("state",1);
        discountUpdateWrapper.eq("id",discount.getId());
        return discountMapper.update(discount,discountUpdateWrapper)==1;
    }
    public boolean disenable(Discount discount){
        UpdateWrapper<Discount> discountUpdateWrapper = new UpdateWrapper<>();
        discountUpdateWrapper.set("state",0);
        discountUpdateWrapper.eq("id",discount.getId());
        return discountMapper.update(discount,discountUpdateWrapper)==1;
    }

    @Override
    public boolean saveBatch(Collection<Discount> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<Discount> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<Discount> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(Discount entity) {
        return false;
    }

    @Override
    public Discount getOne(Wrapper<Discount> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<Discount> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<Discount> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }



    @Override
    public Class<Discount> getEntityClass() {
        return null;
    }
}
